package org.hhchat.leetcode.bit;

/**
 * Created by hh23485 on 2017/6/25.
 */
public class code461 {
    public static class Solution {

        public int hammingDistance(int x, int y) {
            int count=0;
            while(x>0||y>0){
                int modx=0,mody=0;
                if(x>0)
                    modx = x%2;
                if(y>0)
                    mody = y%2;
                if(modx!=mody) count++;
                x/=2;
                y/=2;
            }
            return count;
        }

    }

    public static void main(String[] args){
        Solution solution = new Solution();
        int result = solution.hammingDistance(1,5);
        System.out.println(result);
    }
}
